package com.wrk._2_数组._01_课件;

import java.util.Arrays;
import java.util.Random;

public class _005_打乱顺序 {
    public static void main(String[] args) {
        //定义数组
        int [] array = {1,2,3,4,5};
        //遍历数组
        for (int i = 0; i < array.length; i++) {
            //生成随机索引
            int random = new Random().nextInt(4);
            //System.out.println(random);
            //随机交换
            int proTem =array[i];
            array[i] =array[random];
            array[random] = proTem;
            //System.out.print(array[i]+"\t");
        }
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
    }
}
